<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>本地文件生成视频</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f5f5f5;
        }
        .container {
            background-color: white;
            padding: 30px;
            border-radius: 10px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #333;
            text-align: center;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 5px;
            font-weight: bold;
        }
        input[type="text"], textarea, select, input[type="file"] {
            width: 100%;
            padding: 10px;
            border: 1px solid #ddd;
            border-radius: 5px;
            box-sizing: border-box;
        }
        textarea {
            height: 100px;
            resize: vertical;
        }
        button {
            background-color: #007bff;
            color: white;
            padding: 12px 30px;
            border: none;
            border-radius: 5px;
            cursor: pointer;
            font-size: 16px;
            width: 100%;
        }
        button:hover {
            background-color: #0056b3;
        }
        .flash-messages {
            margin-bottom: 20px;
        }
        .flash-success {
            background-color: #d4edda;
            color: #155724;
            padding: 10px;
            border-radius: 5px;
            border: 1px solid #c3e6cb;
        }
        .flash-error {
            background-color: #f8d7da;
            color: #721c24;
            padding: 10px;
            border-radius: 5px;
            border: 1px solid #f5c6cb;
        }
        .navigation {
            margin-top: 30px;
            text-align: center;
        }
        .nav-link {
            display: inline-block;
            margin: 10px;
            color: #007bff;
            text-decoration: none;
            padding: 10px 20px;
            border: 1px solid #007bff;
            border-radius: 5px;
        }
        .nav-link:hover {
            background-color: #007bff;
            color: white;
        }
        optgroup {
            font-weight: bold;
        }
        option {
            font-weight: normal;
        }
    </style>
</head>
<body>
    <div class="container">
        <h1>本地文件生成视频</h1>
        
        <!-- 显示闪现消息 -->
        <div class="flash-messages">
            {% with messages = get_flashed_messages(with_categories=true) %}
                {% if messages %}
                    {% for category, message in messages %}
                        <div class="flash-{{ category }}">{{ message }}</div>
                    {% endfor %}
                {% endif %}
            {% endwith %}
        </div>
        
        <form action="{{ url_for('local_file_process') }}" method="post" enctype="multipart/form-data">
            <div class="form-group">
                <label for="image_file">选择图片:</label>
                <input type="file" id="image_file" name="image_file" accept="image/*" required>
            </div>
            
            <div class="form-group">
                <label for="prompt">视频描述:</label>
                <textarea id="prompt" name="prompt" placeholder="请输入视频描述，例如：一辆红色的破旧的自行车停在一条泥泞的小路上，背景是茂密的原始森林" required>{{ cached_inputs.prompt or '' }}</textarea>
            </div>
            
            <div class="form-group">
                <label for="negative_prompt">负面描述 (可选):</label>
                <input type="text" id="negative_prompt" name="negative_prompt" placeholder="不希望出现在视频中的元素" value="{{ cached_inputs.negative_prompt or '' }}">
            </div>
            
            <div class="form-group">
                <label for="resolution">分辨率:</label>
                <select id="resolution" name="resolution">
                    <optgroup label="480P">
                        <option value="480P" {% if cached_inputs.resolution == '480P' %}selected{% endif %}>480P (854x480)</option>
                    </optgroup>
                    <optgroup label="720P">
                        <option value="720P" {% if cached_inputs.resolution == '720P' or not cached_inputs.resolution %}selected{% endif %}>720P (1280x720)</option>
                    </optgroup>
                    <optgroup label="1080P">
                        <option value="1080P" {% if cached_inputs.resolution == '1080P' %}selected{% endif %}>1080P (1920x1080)</option>
                    </optgroup>
                </select>
            </div>
            
            <button type="submit">生成视频</button>
        </form>
        
        <div class="navigation">
            <a href="{{ url_for('index') }}" class="nav-link">返回主页</a>
            <a href="{{ url_for('image_edit') }}" class="nav-link">AI图片编辑</a>
            <a href="{{ url_for('task_list') }}" class="nav-link">任务列表</a>
        </div>
    </div>
</body>
</html>